﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{
    static void Main()
    {
        long a = long.Parse(Console.ReadLine());
        long b = long.Parse(Console.ReadLine());
        long c = long.Parse(Console.ReadLine());
        long r = 0L;
        long lastOutput = 0L;

        if (b == 2)
        {
            r = a % c;
        }
        if (b == 4)
        {
            r = a + c;
        }
        if (b == 8)
        {
            r = a * c;
        }

        if (r % 4 == 0)
        {
            lastOutput = r / 4;
        }
        else
        {
            lastOutput = r % 4;
        }

        Console.WriteLine(lastOutput);
        Console.WriteLine(r);

    }
}
